#ifndef TRANSFORMERCONTENTRECORDMEMROYOUT_HPP
#define TRANSFORMERCONTENTRECORDMEMROYOUT_HPP
class TransContentRecordMemoryOut : public TransContentITimerEvent{
	private:
		int sending;
		int working;
		char* sendData;
		int sendDataLen;
		int timeout;
		pthread_mutex_t waitMutex;
		pthread_cond_t waitCond;
		sendToSyncCallback stscb;
		pthread_t workThread;
	public:
		TransContentRecordMemoryOut():sending(0), working(1), sendData(NULL), sendDataLen(0), timeout(INT_MAX), waitMutex(PTHREAD_MUTEX_INITIALIZER), waitCond(PTHREAD_COND_INITIALIZER), stscb(NULL){
			debug_enter();
			pthread_create(&workThread, NULL, workRoute, this);
			pthread_detach(workThread);
			debug_leave();
		}

		int getTimeout();
		void setTimeout(int timeout);

		int sendData(const char* buffer, int len);

		void OnTimer();

	private:
		void sendDataOut(const char* buffer, int len);
		static void* finishRoute(void* p);
		static void* workRoute(void *p){
			(TransContentRecordMemoryOut*(p))->sendWorker();
			return NULL;
		}

		void sendWorker();
		void sendFinished();

};
#endif //TRANSFORMERCONTENTRECORDMEMROYOUT_HPP
